home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / Delphi 3.0 / DATA.Z / CHECKMPL.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-01-30  |  5.9 KB  |  232 lines

  1. unit Checkmpl;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, ActiveX, Classes, Controls, Graphics, Menus, Forms, StdCtrls,
  7.   ComServ, StdVCL, AXCtrls, DelLib;
  8.  
  9. type
  10.   TCheckBoxX = class(TActiveXControl, ICheckBoxX)
  11.   private
  12.     { Private declarations }
  13.     FDelphiControl: TCheckBox;
  14.     FEvents: ICheckBoxXEvents;
  15.     procedure ClickEvent(Sender: TObject);
  16.     procedure KeyPressEvent(Sender: TObject; var Key: Char);
  17.   protected
  18.     { Protected declarations }
  19.     procedure InitializeControl; override;
  20.     procedure EventSinkChanged(const EventSink: IUnknown); override;
  21.     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
  22.     function Get_Alignment: TxLeftRight; safecall;
  23.     function Get_AllowGrayed: WordBool; safecall;
  24.     function Get_Caption: WideString; safecall;
  25.     function Get_Checked: WordBool; safecall;
  26.     function Get_Color: TColor; safecall;
  27.     function Get_Ctl3D: WordBool; safecall;
  28.     function Get_Cursor: Smallint; safecall;
  29.     function Get_DragCursor: Smallint; safecall;
  30.     function Get_Enabled: WordBool; safecall;
  31.     function Get_Font: Font; safecall;
  32.     function Get_ParentColor: WordBool; safecall;
  33.     function Get_State: TxCheckBoxState; safecall;
  34.     function Get_Visible: WordBool; safecall;
  35.     procedure AboutBox; safecall;
  36.     procedure Set_Alignment(Value: TxLeftRight); safecall;
  37.     procedure Set_AllowGrayed(Value: WordBool); safecall;
  38.     procedure Set_Caption(const Value: WideString); safecall;
  39.     procedure Set_Checked(Value: WordBool); safecall;
  40.     procedure Set_Color(Value: TColor); safecall;
  41.     procedure Set_Ctl3D(Value: WordBool); safecall;
  42.     procedure Set_Cursor(Value: Smallint); safecall;
  43.     procedure Set_DragCursor(Value: Smallint); safecall;
  44.     procedure Set_Enabled(Value: WordBool); safecall;
  45.     procedure Set_Font(const Value: Font); safecall;
  46.     procedure Set_ParentColor(Value: WordBool); safecall;
  47.     procedure Set_State(Value: TxCheckBoxState); safecall;
  48.     procedure Set_Visible(Value: WordBool); safecall;
  49.   end;
  50.  
  51. implementation
  52. uses checkPg;
  53. { TCheckBoxX }
  54.  
  55. procedure TCheckBoxX.InitializeControl;
  56. begin
  57.   FDelphiControl := Control as TCheckBox;
  58.   FDelphiControl.OnClick := ClickEvent;
  59.   FDelphiControl.OnKeyPress := KeyPressEvent;
  60. end;
  61.  
  62. procedure TCheckBoxX.EventSinkChanged(const EventSink: IUnknown);
  63. begin
  64.   FEvents := EventSink as ICheckBoxXEvents;
  65. end;
  66.  
  67. procedure TCheckBoxX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  68. begin
  69.   { Define property pages here.  Property pages are defined by calling
  70.     DefinePropertyPage with the class id of the page.  For example,
  71.       DefinePropertyPage(Class_CheckBoxXPage); }
  72. end;
  73.  
  74. function TCheckBoxX.Get_Alignment: TxLeftRight;
  75. begin
  76.   Result := Ord(FDelphiControl.Alignment);
  77. end;
  78.  
  79. function TCheckBoxX.Get_AllowGrayed: WordBool;
  80. begin
  81.   Result := FDelphiControl.AllowGrayed;
  82. end;
  83.  
  84. function TCheckBoxX.Get_Caption: WideString;
  85. begin
  86.   Result := WideString(FDelphiControl.Caption);
  87. end;
  88.  
  89. function TCheckBoxX.Get_Checked: WordBool;
  90. begin
  91.   Result := FDelphiControl.Checked;
  92. end;
  93.  
  94. function TCheckBoxX.Get_Color: TColor;
  95. begin
  96.   Result := FDelphiControl.Color;
  97. end;
  98.  
  99. function TCheckBoxX.Get_Ctl3D: WordBool;
  100. begin
  101.   Result := FDelphiControl.Ctl3D;
  102. end;
  103.  
  104. function TCheckBoxX.Get_Cursor: Smallint;
  105. begin
  106.   Result := Smallint(FDelphiControl.Cursor);
  107. end;
  108.  
  109. function TCheckBoxX.Get_DragCursor: Smallint;
  110. begin
  111.   Result := Smallint(FDelphiControl.DragCursor);
  112. end;
  113.  
  114. function TCheckBoxX.Get_Enabled: WordBool;
  115. begin
  116.   Result := FDelphiControl.Enabled;
  117. end;
  118.  
  119. function TCheckBoxX.Get_Font: Font;
  120. begin
  121.   GetOleFont(FDelphiControl.Font, Result);
  122. end;
  123.  
  124. function TCheckBoxX.Get_ParentColor: WordBool;
  125. begin
  126.   Result := FDelphiControl.ParentColor;
  127. end;
  128.  
  129. function TCheckBoxX.Get_State: TxCheckBoxState;
  130. begin
  131.   Result := Ord(FDelphiControl.State);
  132. end;
  133.  
  134. function TCheckBoxX.Get_Visible: WordBool;
  135. begin
  136.   Result := FDelphiControl.Visible;
  137. end;
  138.  
  139. procedure TCheckBoxX.AboutBox;
  140. begin
  141.   ShowCheckBoxXAbout;
  142. end;
  143.  
  144. procedure TCheckBoxX.Set_Alignment(Value: TxLeftRight);
  145. begin
  146.   FDelphiControl.Alignment := TLeftRight(Value);
  147. end;
  148.  
  149. procedure TCheckBoxX.Set_AllowGrayed(Value: WordBool);
  150. begin
  151.   FDelphiControl.AllowGrayed := Value;
  152. end;
  153.  
  154. procedure TCheckBoxX.Set_Caption(const Value: WideString);
  155. begin
  156.   FDelphiControl.Caption := TCaption(Value);
  157. end;
  158.  
  159. procedure TCheckBoxX.Set_Checked(Value: WordBool);
  160. begin
  161.   FDelphiControl.Checked := Value;
  162. end;
  163.  
  164. procedure TCheckBoxX.Set_Color(Value: TColor);
  165. begin
  166.   FDelphiControl.Color := Value;
  167. end;
  168.  
  169. procedure TCheckBoxX.Set_Ctl3D(Value: WordBool);
  170. begin
  171.   FDelphiControl.Ctl3D := Value;
  172. end;
  173.  
  174. procedure TCheckBoxX.Set_Cursor(Value: Smallint);
  175. begin
  176.   FDelphiControl.Cursor := TCursor(Value);
  177. end;
  178.  
  179. procedure TCheckBoxX.Set_DragCursor(Value: Smallint);
  180. begin
  181.   FDelphiControl.DragCursor := TCursor(Value);
  182. end;
  183.  
  184. procedure TCheckBoxX.Set_Enabled(Value: WordBool);
  185. begin
  186.   FDelphiControl.Enabled := Value;
  187. end;
  188.  
  189. procedure TCheckBoxX.Set_Font(const Value: Font);
  190. begin
  191.   SetOleFont(FDelphiControl.Font, Value);
  192. end;
  193.  
  194. procedure TCheckBoxX.Set_ParentColor(Value: WordBool);
  195. begin
  196.   FDelphiControl.ParentColor := Value;
  197. end;
  198.  
  199. procedure TCheckBoxX.Set_State(Value: TxCheckBoxState);
  200. begin
  201.   FDelphiControl.State := TCheckBoxState(Value);
  202. end;
  203.  
  204. procedure TCheckBoxX.Set_Visible(Value: WordBool);
  205. begin
  206.   FDelphiControl.Visible := Value;
  207. end;
  208.  
  209. procedure TCheckBoxX.ClickEvent(Sender: TObject);
  210. begin
  211.   if FEvents <> nil then FEvents.OnClick;
  212. end;
  213.  
  214. procedure TCheckBoxX.KeyPressEvent(Sender: TObject; var Key: Char);
  215. var
  216.   TempKey: Smallint;
  217. begin
  218.   TempKey := Smallint(Key);
  219.   if FEvents <> nil then FEvents.OnKeyPress(TempKey);
  220.   Key := Char(TempKey);
  221. end;
  222.  
  223. initialization
  224.   TActiveXControlFactory.Create(
  225.     ComServer,
  226.     TCheckBoxX,
  227.     TCheckBox,
  228.     Class_CheckBoxX,
  229.     3,
  230.     '{5A565964-7975-11D0-BE02-00A024D1875C}');
  231. end.
  232.